//
//  ActivityDetailTableViewCell.m
//  TravelFollowYourHeart
//
//  Created by ENERGY on 2017/12/24.
//  Copyright © 2017年 Lwx. All rights reserved.
//

#import "ActivityDetailTableViewCell.h"
#define border 10

@interface ActivityDetailTableViewCell()
@property (nonatomic, strong)UIImageView * headImage;
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UILabel * contentLab;
@property (nonatomic, strong)UIView * borderView;

@end

@implementation ActivityDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.headImage];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.contentLab];
        [self.contentView addSubview:self.borderView];
    }return self;
}

- (UIImageView *)headImage{
    if (!_headImage) {
        _headImage = [[UIImageView alloc] init];
        _headImage.backgroundColor = [UIColor purpleColor];
        
    }return _headImage;
}

- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.text = @"活动时间：";
        _titleLab.font = [UIFont systemFontOfSize:12.0];
        _titleLab.textColor = [UIColor grayColor];
    }return _titleLab;
}

- (UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] init];
        _contentLab.text = @"具体内容";
        _contentLab.font = [UIFont systemFontOfSize:12.0];
        _contentLab.textColor = [UIColor grayColor];
    }return _contentLab;
}

- (UIView *)borderView{
    if (!_borderView) {
        _borderView = [[UIView alloc] init];
        _borderView.backgroundColor = getColor(bgColor);
        
    }return _borderView;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _headImage.frame = CGRectMake(border, 0, 25, 25);
    _headImage.centerY = self.contentView.height / 2;
    if ([self.delegate respondsToSelector:@selector(getWidthWithText:height:font:)]) {
        int titleLabW = [self.delegate getWidthWithText:_titleLab.text height:self.contentView.height font:12.0] + 1;
        _titleLab.frame = CGRectMake(_headImage.right + 5, 0, titleLabW, self.contentView.height);
    }
    int contentLabW = SCREEN_WIDTH - self.titleLab.right;
    _contentLab.frame = CGRectMake(self.titleLab.right, 0, contentLabW, self.contentView.height);
    _borderView.frame = CGRectMake(0, self.contentView.bottom - 1, SCREEN_WIDTH, 1);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
